package com.sgb.link.view.adapter;

import android.content.Context;

import androidx.annotation.DrawableRes;

import com.sgb.link.BR;
import com.sgb.link.R;
import com.sgb.link.databinding.ItemPickSelectBinding;
import com.sgb.link.entity.PickSelectEntity;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;

import java.util.List;

public class IpPickSelectAdapter extends BaseRecycleAdapter<PickSelectEntity> {

    ItemPickSelectBinding binding;
    @DrawableRes
    int color;

    public IpPickSelectAdapter(Context context, List<PickSelectEntity> datas) {
        super(context, R.layout.item_pick_select, datas);
    }

    public IpPickSelectAdapter(Context context, List<PickSelectEntity> datas, @DrawableRes int color) {
        super(context, R.layout.item_pick_select, datas);
        this.color = color;
    }

    @Override
    public void convert(ItemViewHolder holder, PickSelectEntity ipPickSelectEntity) {
        holder.setBinding(BR.viewModel, ipPickSelectEntity);
        binding = (ItemPickSelectBinding) holder.getmBinding();
        if (color != 0) {
            binding.rlRootLayout.setBackground(context.getResources().getDrawable(color));
        }
    }

}
